<?php

namespace app\console\validate;

use app\common\validate\Base;

/**
 * 管理员validate
 * */
class Admin extends Base
{
    protected $rule = [
        'username' => 'require|unique:admin|length:4,16',
        'old_pass' => 'require|alphaDash|length:6,16',
        'new_pass' => 'require|alphaDash|length:6,16|confirm:confirm_pass|different:old_pass',
        'confirm_pass' => 'require|alphaDash|length:6,16',
    ];

    protected $message = [
        'username.require' => '请填写账号',
        'username.unique' => '该账号已存在',
        'username.length' => '账号应为6-16个字符长度',
        'old_pass.require' => '原始密码不得为空',
        'old_pass' => '密码应为6-16个字符的字母数字下划线组合',
        'new_pass.require' => '新密码不得为空',
        'new_pass.confirm' => '新密码与确认密码不一致',
        'new_pass.different' => '新密码不能和原始密码一致',
        'new_pass' => '密码应为6-16个字符的字母数字下划线组合',
        'confirm_pass.require' => '确定密码不得为空',
        'confirm_pass' => '密码应为6-16个字符的字母数字下划线组合',
    ];

    protected $scene = [
        'add' => ['username'],
        'edit' => ['username'],
        'edit_password' => ['old_pass', 'new_pass', 'confirm_pass'],
    ];
}